package cn.edu.swu.book;

import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;

public class BookService {

    private BookRepo repo;
    public static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-mm-dd");

    public BookService(){
    }

    public List<Book> getAll() throws SQLException, ClassNotFoundException {
        return this.repo.getAllBooks();
    }

    public void save(Book book) throws SQLException {
        this.repo.save(book);
    }

    public void deleteById(int id) throws SQLException {
        this.repo.deleteById(id);
    }

    public Book getById(int id) throws SQLException {
        return this.repo.getById(id);
    }


    public List<Book> search(String key) throws SQLException {
        return this.repo.search(key);
    }

    public List<Book> searchByPriceRange(Double minPrice, Double maxPrice) throws SQLException {
        //System.out.println("BookServlet开始调用BookRepo");
        return this.repo.searchByPriceRange(minPrice, maxPrice);
    }

    public void setRepo(BookRepo repo) {
        this.repo = repo;
    }


}
